/**
 * @author (Jeff Thomas) 
 * @version (11.21.2007)
 */

public class MinMaxAccount extends BankAccount {
    //instance variables
    private int min;
    private int max;
    private boolean newAcct;
    //constructor
    public MinMaxAccount(Startup s) {
        super(s);
        min = 0;
        max = 0;
        newAcct = true;
    }
    //returns minimum balance in pennies
    public int getMin() {
        checkMinMax();
        return min;
    }
    //returns maximum balance in pennies
    public int getMax() {
        checkMinMax();
        return max;
    }
    //
    private void checkMinMax() {
        //is this a new account?
        if (newAcct) {
            min = super.getBalance();
            max = super.getBalance();
            newAcct = false;
        }
        else {
            if (super.getBalance() < min)
                min = super.getBalance();
            else if (super.getBalance() > max)
                max = super.getBalance();
        }
    }
}